<?php
/**
 * 提货产品汇总申请
 * (model)
 */
namespace App\Models\Shipping;

use Illuminate\Database\Eloquent\Model;
class SSkuTotalApply extends Model
{
    protected $table = 's_shipping_total_apply';

    protected $guarded = [];

    public $timestamps = false;

    public static function getFile(): string
    {
        $filePath = storage_path('app'.DIRECTORY_SEPARATOR.'synctotal').DIRECTORY_SEPARATOR.date('YmdHis').'.csv';
        $fileDir = dirname($filePath);
        if(!is_dir($fileDir)){
            mkdir($fileDir,0777,true);
            chmod($fileDir, 0777);
        }
        return $filePath;
    }
    public static function getApplyNum($pSkuId,$sDate,$eDate){
        return self::query()
            ->where('psku_id',$pSkuId)
            ->where('shipping_date','>=',$sDate)
            ->where('shipping_date','<=',$eDate)
            ->pluck('apply_num','shipping_date')
            ->toArray();
    }
}
